package com.galaxy.maven.tools.autoconfig;

import java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * @goal autoconf
 * @phase process-sources
 */
public class AutoConfigMojo extends AbstractMojo {

    /**
     * @parameter expression="${autoconf.webContentPath}" default-value="${basedir}/WebContent"
     */
    private String webContentPath;
    
    /**
     * @parameter expression="${autoconf.resourcesPath}" default-value="${basedir}/src/main/resources"
     */
    private String resourcesPath;
    
    /**
     * @parameter expression="${autoconf.configFile}" default-value="${basedir}/WebContent/META-INF/autoConfig/auto-config.xml"
     */
    private String configFile;
    
    /**
     * @parameter expression="${autoconf.propertiesFile}" default-value="${user.home}/autoconf.properties"
     */
    private String propertiesFile;

    public void execute() throws MojoExecutionException {
        ConfigSetter configSetter = new ConfigSetter();
        File fWebContentPath = new File(webContentPath);
        File fResourcesPath = new File(resourcesPath);
        File fConfigFile = new File(configFile);
        File fPropertiesFile = new File(propertiesFile);
        configSetter.addValuesToFile(fWebContentPath,fResourcesPath, fConfigFile, fPropertiesFile);
        getLog().info(webContentPath);
        getLog().info(resourcesPath);
        getLog().info(configFile);
        getLog().info(propertiesFile);
    }
}
